//
//  HZAdViewController.m
//  WangYiNews
//
//  Created by WangPengHua on 16/1/10.
//  Copyright © 2016年 PengHua Wang. All rights reserved.
//

#import "HZAdViewController.h"
#import "HZMainTabBarController.h"
@interface HZAdViewController ()

@end

@implementation HZAdViewController
#pragma mark - 生命周期方法
- (void)viewDidLoad {
    [super viewDidLoad];
    // 1. 设置背景图片
    UIImageView *backgroundImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Default"]];
    
    [self.view addSubview:backgroundImageView];
    
    backgroundImageView.frame = self.view.bounds;
    
    // 2. 设置广告图片
    UIImageView *adImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ad"]];
    
    [self.view addSubview:adImageView];
    
    adImageView.width = 306;
    adImageView.height = 310;
    adImageView.centerX = self.view.centerX;
    adImageView.centerY = self.view.centerY;
    
    //3. 广告之后,获取主窗口,跳转mainTabBarVc
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW,(int64_t)(2.0 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
        //获取主窗口
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        
        HZMainTabBarController *mainTabBarVc = [[HZMainTabBarController alloc]init];
        //设置window的根控制器
        window.rootViewController = mainTabBarVc;
        
    });
    
}
#pragma mark - 收到内存警告的方法处理
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
